//
//  ClassManageManViewController.m
//  Ai
//
//  Created by 杜超男 on 2019/3/6.
//  Copyright © 2019年 杜超男. All rights reserved.
//

#import "ClassManageManViewController.h"
#import "AddManagerAndClassViewController.h"
@interface ClassManageManViewController ()<UITableViewDelegate , UITableViewDataSource>
@property (nonatomic , strong)UITableView *tableView;
@property (nonatomic , strong)NSMutableArray *DataSoure;
@end

@implementation ClassManageManViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    [self.view addSubview:self.tableView];
}
-(NSMutableArray *)DataSoure{
//    _DataSoure = [NSMutableArray arrayWithObjects:@"小小班" , @"小小班", @"小小班" , @"小小班" , @"小小班" , @"小小班" ,  nil];
    return _DataSoure;
}
-(UITableView *)tableView{
    _tableView = [[UITableView alloc] initWithFrame:self.view.frame style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    return _tableView;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.DataSoure.count;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
//    cell.textLabel.text = self.DataSoure[indexPath.row];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    return cell;
}
//-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
//    [self.navigationController pushViewController:[AddClassManagerManViewController new] animated:YES];
//}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
    self.tabBarController.tabBar.hidden = NO;
    NSUserDefaults *DataSoureUFS = [[NSUserDefaults alloc] init];
    self.DataSoure = [NSMutableArray arrayWithArray:[DataSoureUFS valueForKey:@"ManagerClassNameDataSoure"]];
    if (self.DataSoure.count == 0) {
        UIButton *AddBtn  =[[UIButton alloc] initWithFrame:CGRectMake((self.view.frame.size.width - 200)/2, 250, 200, 40)];
        [AddBtn setTitle:@"+  添加班级管理员" forState:UIControlStateNormal];
        //rgba(103/255.0, 194/255.0, 86/255.0, 1)
        [AddBtn setBackgroundColor: [UIColor colorWithRed:103/255.0 green:194/255.0 blue:86/255.0 alpha:1]];
        [AddBtn setTintColor:[UIColor whiteColor]];
        [AddBtn addTarget:self action:@selector(AddBtnSome) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:AddBtn];
    }else{
        [self.view addSubview:self.tableView];
    }
}
- (void)viewWillDisappear:(BOOL)animated{
    //    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
    //    [self.navigationController.navigationBar setShadowImage:nil];
}
- (void)AddBtnSome{
    [self.navigationController pushViewController:[AddManagerAndClassViewController new] animated:YES];
}
@end
